<?php

namespace Data;

class Cms extends Base {

	const TYPE_ABOUT = 1;

	const TYPE_CONTACT = 2;

	public function getAbout() {
		$result = $this->where(array('Type' => self::TYPE_ABOUT))->findOne();
		$content = empty($result['Content']) ? '' : $result['Content'];
		return $content;
	}

	public function saveAbout($content) {
		$result = array(
			'Type' => self::TYPE_ABOUT,
			'Content' => $content,
			'UpdateTime' => time(),
		);
		$this->replace($result);
	}

	public function getContact() {
		$result = $this->where(array('Type' => self::TYPE_CONTACT))->findOne();
		$content = empty($result['Content']) ? '' : $result['Content'];
		return $content;
	}

	public function saveContact($content) {
		$result = array(
			'Type' => self::TYPE_CONTACT,
			'Content' => $content,
			'UpdateTime' => time(),
		);
		$this->replace($result);
	}

}